import $ from './jquery.js';

$.ajax({
  type: "get",
  url: "../interface/getitems.php",
  dataType: "json"
}).then(res => {
  let template = '';
  console.log(res);

  // console.log(JSON.parse(res[1].picture).src);
  res.forEach(el => {
    let pic = JSON.parse(el.picture);
    console.log(pic);
    // console.log(el.title);
    // console.log(el.id);
    console.log(pic[0].src);

    template += `     <div class=" commodity">       
    <a href="./detailed.html?id=${el.id}">
        <img src="${pic[0].src}" alt="" class="commodity-bg">
        <div class="commodity-name">${el.title}</div>
        <span>￥${el.price}</span>
    </a>
    </div>
`;

  });


  $('.php-1').html(template);

}).catch(xhr => {
  console.log(xhr.status);
});